package df.bean.db.table;

import df.bean.db.conn.DBConnection;
import df.bean.obj.util.JDate;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Om 5/01/10
*/
public class IntHisDc extends ABSTable {

    public IntHisDc(DBConnection conn) {
        super();
        this.setDBConnection(conn);
    }   
    public boolean rollBackDelete(String hospitalCode, String startDate, String endDate) {
        List sqlCommand = new ArrayList();
        boolean ret = false;
        String sql = "DELETE FROM INT_HIS_DC " 
                    + " WHERE TRANSACTION_DATE >= '" + startDate + "' AND TRANSACTION_DATE <= '" + endDate + "'"
                    + " AND HOSPITAL_CODE = '" + hospitalCode + "'";
        sqlCommand.add( sql );
        System.out.println(sql);
        ret = super.rollBack(sqlCommand);
        return ret;
    } 
    //update
    public boolean rollBackUpdateTrn(String hospitalCode, String startDate, String endDate) {
        List sqlCommand = new ArrayList();
        boolean ret = false;
        String sql = "UPDATE TRN_DAILY SET ACTIVE='1', IS_DC='N' " +
        " WHERE HOSPITAL_CODE = '" + hospitalCode + "'" +
        " AND (HOSPITAL_CODE + INVOICE_NO + LINE_NO + DOCTOR_CODE) IN " + 
    	 " (SELECT HOSPITAL_CODE + INVOICE_NO + ACCESSION_NUMBER + DOCTOR_CODE " + 
    	 "    	FROM INT_HIS_DC " +
        " 		WHERE HOSPITAL_CODE = '" + hospitalCode + "'" +
        " 		AND (TRANSACTION_DATE >= '" + startDate + "' AND TRANSACTION_DATE <= '" + endDate + "'))"+
        "       AND (BATCH_NO IS NULL OR BATCH_NO = '')";
       // " AND TRANSACTION_DATE BETWEEN '" + startDate + "' AND '" + endDate + "')";
        System.out.println(sql);
        sqlCommand.add( sql );
        ret = super.rollBack(sqlCommand);
        return ret;
    } 
}
